#ifndef LAPI_LOG_H
#define LAPI_LOG_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>

#include "lapi.h"

#ifdef LAPI_X86
#define LAPI_LOG_FILE "/download/lapi_log.txt"
#define LAPI_LOG_FILE_PREV "/download/lapi_log_prev.txt"
#define DETAILED_LOG "/download/detailed_log.txt"
#define BRIEF_LOG    "/download/brief_log.txt"
#define AGPS_LOG     "/download/agps_log.txt"
#else
#define LAPI_CFG_PATH        "/data/location"
#ifndef LAPI_LOG_PATH
#define LAPI_LOG_PATH        "/local/log/location"
#endif
#define LAPI_LOG_FILE        "/local/log/location/lapi_log.txt"
/*#define LAPI_LOG_FILE_PREV  lapi_log_file_prev() 
#define DETAILED_LOG        detailed_log() 
#define BRIEF_LOG           brief_log()
#define AGPS_LOG            agps_log()
#define AGPS_LOG_FILENAME           agps_log_filename()
#define PREVIOUS_LOCATION_FILENAME  previous_location_filename()
#define BRIEF_LOG_FILENAME          brief_log_filename()
#define DETAILED_LOG_FILENAME       detailed_log_filename()
#define SLC_LOG_FILENAME            slc_log_filename()*/
#endif

/*
 * Global flag for debug mode
 *
 * 0 - debug mode off, can't output logs (it's for no log build)
 * 1 - debug mode on, can output logs
 */
extern int g_debug_mode;

// 2MB for debug
#define LAPI_LOG_FILE_MAX_LEN (1024*1024*2)
#define FILE_PATH_LEN 64

/*
 * log level to control output
 *
 * it's a env var for Borqs Modem Service team
 *
 * char* env_log_level = getenv("TELEPHONY_LOG_LEVEL");
 *
 */
#define LOG_LEVEL_VERBOSE 6
#define LOG_LEVEL_DEBUG 5
#define LOG_LEVEL_INFO 4
#define LOG_LEVEL_WARN 3
#define LOG_LEVEL_ERROR 2
#define LOG_LEVEL_FATAL 1
#define LOG_LEVEL_DISABLED 0

/*char str_log_dir[FILE_PATH_LEN];
char str_log_file[FILE_PATH_LEN];
char str_log_file_prev[FILE_PATH_LEN];
char str_detailed_log[FILE_PATH_LEN];
char str_brief_log[FILE_PATH_LEN];
char str_agps_log[FILE_PATH_LEN];
char str_agps_log_filename[FILE_PATH_LEN];
char str_previous_location_filename[FILE_PATH_LEN];
char str_brief_log_filename[FILE_PATH_LEN];
char str_detailed_log_filename[FILE_PATH_LEN];
char str_slc_log_filename[FILE_PATH_LEN];

char *lapi_log_dir();
char *lapi_log_file();
char *lapi_log_file_prev();
char *detailed_log(); 
char *brief_log();
char *agps_log();
char *agps_log_filename();
char *previous_location_filename();
char *brief_log_filename();
char *detailed_log_filename();
char *slc_log_filename();*/

int lapi_log_start(void);
void lapi_log_stop(void);

void lapi_log(int log_level, const char *fmt, ...);
void log_dispatcher(LAPI_LOG_LEV lev, const char *fmt, ...);

#endif
